package cn.xwt.weidisk.pojo.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * @author 薛慰涛
 */
public class LocationData {
    private int status;
    private String message;
    private Result result;

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Result getResult() {
        return result;
    }

    public void setResult(Result result) {
        this.result = result;
    }

    public String getLocation() {
        String location;
        try {
            String province = result.getAdInfo().getProvince();
            if (!"".equals(province)) {
                location = result.getAdInfo().getProvince() +
                        " " +
                        result.getAdInfo().getCity() +
                        " " +
                        result.getAdInfo().getDistrict();
            } else {
                location = "无法定位";
            }

        } catch (Exception e) {
            location = "无法定位";
        }
        return location;
    }

    @Override
    public String toString() {
        return "LocationInfo{" +
                "status=" + status +
                ", message='" + message + '\'' +
                ", result=" + result +
                '}';
    }
}

class Result {
    private String ip;
    private Location location;
    @JsonProperty("ad_info")
    private AdInfo adInfo;

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public AdInfo getAdInfo() {
        return adInfo;
    }

    public void setAdInfo(AdInfo adInfo) {
        this.adInfo = adInfo;
    }

    @Override
    public String toString() {
        return "Result{" +
                "ip='" + ip + '\'' +
                ", location=" + location +
                ", adInfo=" + adInfo +
                '}';
    }
}

class Location {
    private int lat;
    private int lng;

    public int getLat() {
        return lat;
    }

    public void setLat(int lat) {
        this.lat = lat;
    }

    public int getLng() {
        return lng;
    }

    public void setLng(int lng) {
        this.lng = lng;
    }

    @Override
    public String toString() {
        return "Location{" +
                "lat=" + lat +
                ", lng=" + lng +
                '}';
    }
}

class AdInfo {
    private String nation;
    private String province;
    private String city;
    private String district;
    private int adcode;

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public int getAdcode() {
        return adcode;
    }

    public void setAdcode(int adcode) {
        this.adcode = adcode;
    }

    @Override
    public String toString() {
        return "AdInfo{" +
                "nation='" + nation + '\'' +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", district='" + district + '\'' +
                ", adcode=" + adcode +
                '}';
    }
}

